﻿using BaoVeThanhDia.Buttons;
using Microsoft.Phone.Controls;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using System.Collections.Generic;

namespace BaoVeThanhDia.MapAndUpgrade
{
    class ItemMap
    {
        int Index;//  từ 00 đến 59
        Button Icon;
        int Star;
        bool isOpen;
        Vector2 position;
        Texture2D imageStar;
        public ItemMap(int index, bool open, int star)
        {
            this.Index = index;
            setValue(open, star);
            setPosition();
            Icon = new Button("icon", "images/mapandupgrade/huyhieu" + index / 10, position, new Vector2(0, 0), new Vector2(60, 60), 0.5f);
        }
        public void setPosition()
        {
            position = new Vector2(600 + 100 * (Index / 10), 100 * (Index % 10));
            switch (Index)
            {
                #region đồng cỏ
                case 0: position = new Vector2(10, 560); break;
                case 1: position = new Vector2(110, 520); break;
                case 2: position = new Vector2(270, 520); break;
                case 3: position = new Vector2(120, 430); break;
                case 4: position = new Vector2(40, 390); break;
                case 5: position = new Vector2(80, 310); break;
                case 6: position = new Vector2(190, 320); break;
                case 7: position = new Vector2(280, 390); break;
                case 8: position = new Vector2(395, 415); break;
                case 9: position = new Vector2(405, 500); break;
                #endregion
                #region thảo nguyên
                case 10: position = new Vector2(220, 770); break;
                case 11: position = new Vector2(300, 700); break;
                case 12: position = new Vector2(380, 710); break;
                case 13: position = new Vector2(450, 750); break;
                case 14: position = new Vector2(485, 680); break;
                case 15: position = new Vector2(420, 620); break;
                case 16: position = new Vector2(525, 600); break;
                case 17: position = new Vector2(650, 660); break;
                case 18: position = new Vector2(680, 740); break;
                case 19: position = new Vector2(770, 750); break;
                #endregion
                #region lâu đài
                case 20: position = new Vector2(1220, 530); break;
                case 21: position = new Vector2(1100, 600); break;
                case 22: position = new Vector2(1080, 700); break;
                case 23: position = new Vector2(1220, 780); break;
                case 24: position = new Vector2(1380, 740); break;
                case 25: position = new Vector2(1470, 720); break;
                case 26: position = new Vector2(1200, 700); break;
                case 27: position = new Vector2(1270, 650); break;
                case 28: position = new Vector2(1330, 600); break;
                case 29: position = new Vector2(1390, 545); break;
                #endregion
                #region núi lửa
                case 30: position = new Vector2(1450, 510); break;
                case 31: position = new Vector2(1350, 410); break;
                case 32: position = new Vector2(1100, 400); break;
                case 33: position = new Vector2(1150, 320); break;
                case 34: position = new Vector2(1250, 350); break;
                case 35: position = new Vector2(1400, 350); break;
                case 36: position = new Vector2(1300, 260); break;
                case 37: position = new Vector2(1450, 240); break;
                case 38: position = new Vector2(1470, 320); break;
                case 39: position = new Vector2(1500, 420); break;
                #endregion
                #region núi độc
                case 40: position = new Vector2(630, 450); break;
                case 41: position = new Vector2(700, 500); break;
                case 42: position = new Vector2(820, 530); break;
                case 43: position = new Vector2(930, 500); break;
                case 44: position = new Vector2(830, 430); break;
                case 45: position = new Vector2(700, 350); break;
                case 46: position = new Vector2(800, 310); break;
                case 47: position = new Vector2(930, 350); break;
                case 48: position = new Vector2(1000, 400); break;
                case 49: position = new Vector2(1020, 480); break;
                #endregion
                #region núi băng
                case 50: position = new Vector2(820, 220); break;
                case 51: position = new Vector2(930, 270); break;
                case 52: position = new Vector2(1070, 230); break;
                case 53: position = new Vector2(1140, 180); break;
                case 54: position = new Vector2(1200, 140); break;
                case 55: position = new Vector2(1180, 70); break;
                case 56: position = new Vector2(1090, 40); break;
                case 57: position = new Vector2(1050, 150); break;
                case 58: position = new Vector2(920, 190); break;
                case 59: position = new Vector2(960, 120); break;
                #endregion
            }
        }
        public void setValue(bool open, int star)
        {
            isOpen = open;
            Star = star;
        }
        public void Load(ContentManager contentManager)
        {
            Icon.Load(contentManager);
            imageStar = contentManager.Load<Texture2D>("images/mapandupgrade/sao" + Star.ToString());
        }
        public void Draw(SpriteBatch spriteBatch, Vector2 Dolech, float scaleZoom)
        {
            if (isOpen)
            {
                Icon.Draw(spriteBatch, Dolech, 0.5f * scaleZoom);
                spriteBatch.Draw(imageStar, (position + new Vector2(3, -16)) * 0.5f * scaleZoom + Dolech, new Rectangle(0, 0, 50, 25), Color.White, 0, Vector2.Zero, 0.5f * scaleZoom, SpriteEffects.None, 0);
            }
        }
        public bool isTouch(Vector2 touch, Vector2 Dolech, float mscale)
        {
           //if (isOpen)
            {
                return Icon.isTouch(touch, Dolech,mscale);
            }
            //else return false;
        }
        public int getIndex() { return Index; }
        public void setTouch(bool touch) { Icon.setTouch(touch); }
    }
}
